// Assault

Assault        = {}
Assault.Client = LocalPlayer()

// Files

local Files = file.FindInLua("Assault/Core/*.lua")

// Loop

for K, V in pairs(Files) do
	include("Core/"..V)
end

// Think

function Assault.Think()
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodeThink")
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			local Visible = vgui.CursorVisible()
			
			// Check visible
			
			if (!Visible) then
				gui.EnableScreenClicker(true)
			end
			
			// On entity think
			
			Assault.Entities.EntitiesRunHook({"OnEntityThink", "OnHandlePhysics"})
		end
	end
end

hook.Add("Think", "Assault.Think", Assault.Think)

// HUDDrawScoreBoard

function Assault.HUDDrawScoreBoard()
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodePaint")
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			Assault.Entities.EntitiesRunHook("OnEntityPaint")
		end
	end
end

hook.Add("HUDDrawScoreBoard", "Assault.HUDDrawScoreBoard", Assault.HUDDrawScoreBoard)

// KeyPressed

function Assault.KeyPress(Player, Key)
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodePlayerKeyPress", Key)
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			Assault.Entities.EntitiesRunHook("OnPlayerKeyPress", Key)
		end
	end
end

hook.Add("KeyPress", "Assault.KeyPress", Assault.KeyPress)

// KeyRelease

function Assault.KeyRelease(Player, Key)
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodePlayerKeyRelease", Key)
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			Assault.Entities.EntitiesRunHook("OnPlayerKeyRelease", Key)
		end
	end
end

hook.Add("KeyRelease", "Assault.KeyRelease", Assault.KeyRelease)

// GUIMousePressed

function Assault.GUIMousePressed(Code)
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodePlayerMousePressed", Code)
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			Assault.Entities.EntitiesRunHook("OnPlayerMousePressed", Code)
		end
	end
end

hook.Add("GUIMousePressed", "Assault.GUIMousePressed", Assault.GUIMousePressed)

// GUIMouseReleased

function Assault.GUIMouseReleased(Code)
	// Gamemode
	
	if (Assault.Gamemode.Active) then
		Assault.Gamemode.Active:GamemodeRunHook("OnGamemodePlayerMouseReleased", Code)
	end
	
	// Level
	
	if (Assault.Level.Loaded) then
		if (!Assault.Level.Paused) then
			Assault.Entities.EntitiesRunHook("OnPlayerMouseReleased", Code)
		end
	end
end

hook.Add("GUIMouseReleased", "Assault.GUIMouseReleased", Assault.GUIMouseReleased)